# -*- coding: utf-8 -*-
#
# @Time    ： 2021/9/12  15:04
# @Auther  ： 徐良
# File     :  editPanel.py

from PySide6.QtWidgets import QWidget
from PySide6.QtCore import Qt, Signal

from mesParts.editPanel.ui.editUI import Ui_Form


class EditPanel(QWidget, Ui_Form):
    editContent = Signal(dict)  # 子界面类创建信号用来绑定主界面类的函数方法

    def __init__(self, paraMap):
        super(EditPanel, self).__init__()
        self.setAttribute(Qt.WA_StyledBackground)
        self.setupUi(self)
        self.setWindowModality(Qt.ApplicationModal)  # 设置为模态

        self.value = paraMap['value']
        self.index = paraMap['index']
        self.model = paraMap['model']

        self.textEdit.setText(self.value)

        self.retMap = {}                # 返回值字典

    def closeEvent(self, event):
        value = self.textEdit.toPlainText()
        self.retMap.clear()
        self.retMap['value'] = value
        self.retMap['index'] = self.index
        self.retMap['model'] = self.model

        self.editContent.emit(self.retMap)


if __name__ == '__main__':
    import sys
    from PySide6.QtWidgets import QApplication
    app = QApplication(sys.argv)
    d = {'value': '1', 'index': 2, 'model': 3}
    window = EditPanel(d)
    window.show()
    sys.exit(app.exec_())